// 封装所有和部门相关的接口请求
import request from '@/utils/request'

export const getDepartments = () =>
  request({
    url: '/company/department'
  })

export const getManagerList = () =>
  request({
    url: '/sys/user/simple'
  })

/**
 * 用于增加子部门
 * @param {*} data 5个
 * @returns 返回这次请求
 */
export const addDepartments = data =>
  request({
    url: '/company/department',
    method: 'post',
    data
  })

// 编辑涉及两个接口
/**
 * 根据部门id获取详情
 * @param {*} id 部门id
 * @returns 返回请求
 */
export const getDepartDetail = (id) => request({
  url: `/company/department/${id}`
})
/**
 * 编辑部门
 * @param {*} data 编辑部门需要7个字段  id,
pid,
name,
code,
managerId,
introduce,
createTime

 * @returns 返回请求
 */
export const editDepartment = (data) => request({
  url: `/company/department/${data.id}`,
  method: 'put',
  data
  // {
  //   id,
  //   pid,
  //   name,
  //   code,
  //   managerId,
  //   introduce,
  //   createTime
  // }
})

// 大型公司  专门负责根据接口文档写api接口封装 => 拧螺丝

export const deleteDepartment = (id) => request({
  url: `/company/department/${id}`,
  method: 'delete'
})

// 增删改查业务 => 1 + 1 + 1 + 2(回显) = 5
